package cn.rkylin.oms.refund.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.taobao.api.domain.Refund;

import cn.rkylin.core.service.ApolloService;
import cn.rkylin.oms.ectrade.vo.EcTradeVO;
import cn.rkylin.oms.refund.dao.IRefundDAO;
import cn.rkylin.oms.refund.vo.EcRefundItemVO;
import cn.rkylin.oms.refund.vo.RefundVO;

@Service("refundService")
public class RefundServiceImpl extends ApolloService implements IRefundService {

	/**
	 * 平台商品数据访问
	 */
	@Autowired
	private IRefundDAO refunDAO;

	public IRefundDAO getRefunDAO() {
		return refunDAO;
	}

	public void setRefunDAO(IRefundDAO refunDAO) {
		this.refunDAO = refunDAO;
	}

	/**
	 * 根据RefundCode找EcRefund
	 * 
	 * @return
	 * @throws Exception
	 */
	@Override
	@Cacheable(value = "RefundVO", key = "T(String).valueOf('ecRefund:').concat(#refundVO.shopId).concat(':').concat(#refundVO.ecTradeCode)")
	public List<RefundVO> findByRefundCode(RefundVO refundVO) throws Exception {
		// TODO Auto-generated method stub
		List<RefundVO> list = findPage("selectByRefundCodeRefund", refundVO);
		return list;

	}

	/**
	 * 根据ID找EcRefund
	 */
	@Override
	public RefundVO getEcRefundById(String id) throws Exception {
		RefundVO vo = refunDAO.findById(id);
		return vo;
	}

	/**
	 * 明细列表的数据抽出
	 */
	@Override
	public PageInfo<RefundVO> findByWhere(int page, int rows, RefundVO ecRefundVO) throws Exception {
		PageInfo<RefundVO> ecoVOList = findPage(page, rows, "pageSelectEcRefund", ecRefundVO);
        return ecoVOList;
	}

	/**
	 * 各个tab的记录数取得
	 */
	@Override
	public List<RefundVO> findCounts(RefundVO ecRefundVO) throws Exception {
		List<RefundVO> list =  findPage("selectRefundCounts",ecRefundVO);
    	return list;
	}
	
	@Override
	public PageInfo<EcRefundItemVO> findByWhere(int page, int rows, EcRefundItemVO ecRefundItemVO) throws Exception {
		PageInfo<EcRefundItemVO> ecoVOList = findPage(page, rows, "pageSelectEcRefundItem", ecRefundItemVO);
        return ecoVOList;
	}

}
